package com.sltx.controller;

import com.sltx.controller.base.BaseController;
import com.sltx.service.LishijiluService;
import com.sltx.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author Administrator
 * @Date 2023/3/27 9:13
 */

@RestController
@ResponseBody
@RequestMapping("/lishi")
public class ALishijiluController extends BaseController {

    @Autowired
    private LishijiluService lishijiluService;

    //展示搜索历史
    @RequestMapping("/jilu")
    @ResponseBody
    public Object lishi(){
        PageData pd = this.getPageData();
        //搜索历史
        List<Object> list = lishijiluService.getLishi(pd);
        return list;
    }

    //添加搜索记录
    @RequestMapping("/insertlishi")
    public void insertlishi(){
        PageData pd = this.getPageData();
        lishijiluService.insertlishi(pd);
    }

    //根据企业名称删除
    @RequestMapping("/deleteentname")
    public void deleteEntname (){
        PageData pd = this.getPageData();
        lishijiluService.deleteEntname(pd);
    }

    //全部删除
    @RequestMapping("/delete")
    public void delete(){
        PageData pd = this.getPageData();
        lishijiluService.delete(pd);
    }

    @Scheduled(cron = "0 0 0 ? * SUN ") //每周日晚上12点运行一次
    public void doTask(){
        //全部删除
    lishijiluService.deleteList();
    }

}
